# from flask import request, jsonify, current_app
# from gevent.threadpool import ThreadPoolExecutor
#
# from app import executor
# from app.libs.enums import SMSType
# from app.libs.error_code import ClientTypeError, Success, ParameterException
# from app.libs.redprint import Redprint
# from app.models.user import User
# from app.models.writer import Writer
# from app.validators.User import ClientForm, UserEmailForm, AdminAddUserForm, WriterRegisterForm,SMSForm
# from app.libs.enums import ClientTypeEnum
# #from app.verify.SMSService import SMSService
# from app.verify.AlismsService import SMSService
#
# api = Redprint('client')
#
#
# #注册 或 超管创建客服
# @api.route('/register', methods=['POST'])
# def create_client():
#     form = ClientForm().validate_for_api()
#     promise = {
#         ClientTypeEnum.USER_EMAIL: __register_user_by_email,
#         ClientTypeEnum.Admin_Create: __register_user_by_admin,
#         ClientTypeEnum.WRITER_REGISTER:__register_user_by_writer
#     }
#     promise[form.type.data]()
#     return Success()
#
#
# @api.route('/sendSMS', methods=['POST'])
# def sendSMS():
#     form = SMSForm().validate_for_api()
#
#     # 异步短信
#     app = current_app._get_current_object()
#     executor.submit(__sendSMS, form.phone_number.data, SMSType.Register.value, app)
#
#     return Success()
#
#
# def __sendSMS(phone, smstype, app):
#     with app.app_context():
#         sms = SMSService(smstype)
#         sms.sendSMS(phone)
#
#
# def __register_user_by_email():
#     form = UserEmailForm().validate_for_api()
#     User.register_by_email(form)
#
#
# def __register_user_by_admin():
#     form = AdminAddUserForm().validate_for_api()
#     User.register_by_admin(form)
#
#
# def __register_user_by_writer():
#     form = WriterRegisterForm().validate_for_api()
#     Writer.register_by_writer(form)
